`timescale 1ns/1ps
module RedLED(Ac, clk, rst, RLED);
  input Ac;        //
  input clk;       //
  input rst;       //
  output RLED;     //
  
  wire Ac;
  wire clk;
  wire rst;
  wire RLED;
  reg [23:0] count;
  
  always @ (posedge clk or posedge rst)
  if(rst == 1'b1)
  begin
    if(Ac == 1'b0 && count == 0)   //if Access is not allowed
    begin
      //then Red LED would be turned on for 5 seconds
      RLED = 1'b1;
      count <= count + 1;
    end
    else if(count <= 1E7)
    begin
      RLED = 1'b1;
      count <= count + 1;
    end
    else
    begin
      //otherwise in will always be off
      RLED = 1'b0;
      count <= 0;
    end
  end
  else
  begin
    RLED = 1'b0;
    count <= 0;
  end
endmodule
